/**
 * 
 */
package com.df.tv.tm.aidl;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author lcw 2014-5-7 下午4:22:18
 */
public class AppInfoEntity implements Parcelable {
    /** 应用编号 */
    private String appid;
    /** 应用名称 */
    private String appname;
    /** apk名称==packageName */
    private String apkname;
    /** apk的下载路径 */
    private String path;
    /** 产品包id */
    private String productId;
    /** 应用描述 */
    private String remark;
    /** 图片路径1(未安装时的黑图) */
    private String img1;
    /** 图片路径2（安装后的彩图） */
    private String img2;
    /** 版本号 */
    private String ver;
    /** 是否可被卸载，1：可卸载 2：不可卸载,defaut 1 */
    private int isUnstall = 1;
    /** 0: 系统服务,1: 用户体验,2: 独立客户端,3: 主客户端,4: 子客户端,5: 其他 */
    private int appType;
    /** 1：强制升级,2：可选升级,3：检测升级,4：静默升级 以上4个为AMS的值，理论上强制和静默是一样的，可选和检测是一样的。5：删除 */
    private int updateType = UpdateType.MAYBE_UPGRADE;

    /** 来自本地app */
    private boolean isLocalApp = false;
    /** 本地App Icon */
    private Bitmap iconBitmap = null;
    /** 当前状态[1.未安装，可安装；2，已安装，可更新级;3.已安装，无更新] */
    private int installState = InstallStates.NO_INSTALL_CAN_INSTALL;

    public interface UpdateType {
        /** 1：强制升级 */
        int FOCE_UPGRADE = 1;
        /** default value 2：可选升级 可选和检测是一样的 */
        int MAYBE_UPGRADE = 2;
        /** 3：检测升级 */
        int CHECK_UPGRADE = 3;
        /** 4：静默升级 以上4个为AMS的值，理论上强制和静默是一样的 */
        int SILENT_UPGRADE = 4;
        /** 5：删除 */
        int DELETE = 5;
    }

    public interface InstallStates {
        /** 1.未安装，可安装； */
        int NO_INSTALL_CAN_INSTALL = 1;
        /** 2，已安装，可更新级; */
        int HAS_INSTALL_CAN_UPDATE = 2;
        /** 3.已安装，无更新 */
        int HAS_INSTALL_NO_UPDATE = 3;
    }

    public AppInfoEntity() {}

    private AppInfoEntity(Parcel in) {
        readFromParcel(in);
    }

    /**
     * @see #appid
     * @return the appid
     */
    public String getAppid() {
        return appid;
    }

    /**
     * @see #appid
     * @param appid
     *            the appid to set
     */
    public void setAppid(String appid) {
        this.appid = appid;
    }

    /**
     * @see #appname
     * @return the appname
     */
    public String getAppname() {
        return appname;
    }

    /**
     * @see #appname
     * @param appname
     *            the appname to set
     */
    public void setAppname(String appname) {
        this.appname = appname;
    }

    /**
     * @see #apkname
     * @return the apkname
     */
    public String getApkname() {
        return apkname;
    }

    /**
     * @see #apkname
     * @param apkname
     *            the apkname to set
     */
    public void setApkname(String apkname) {
        this.apkname = apkname;
    }

    /**
     * @see #path
     * @return the path
     */
    public String getPath() {
        return path;
    }

    /**
     * @see #path
     * @param path
     *            the path to set
     */
    public void setPath(String path) {
        this.path = path;
    }

    /**
     * @see #productId
     * @return the productId
     */
    public String getProductId() {
        return productId;
    }

    /**
     * @see #productId
     * @param productId
     *            the productId to set
     */
    public void setProductId(String productId) {
        this.productId = productId;
    }

    /**
     * @see #remark
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @see #remark
     * @param remark
     *            the remark to set
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * @see #img1
     * @return the img1
     */
    public String getImg1() {
        return img1;
    }

    /**
     * @see #img1
     * @param img1
     *            the img1 to set
     */
    public void setImg1(String img1) {
        this.img1 = img1;
    }

    /**
     * @see #img2
     * @return the img2
     */
    public String getImg2() {
        return img2;
    }

    /**
     * @see #img2
     * @param img2
     *            the img2 to set
     */
    public void setImg2(String img2) {
        this.img2 = img2;
    }

    /**
     * @see #ver
     * @return the ver
     */
    public String getVer() {
        return ver;
    }

    /**
     * @see #ver
     * @param ver
     *            the ver to set
     */
    public void setVer(String ver) {
        this.ver = ver;
    }

    /**
     * @see #isUnstall
     * @return the isUnstall
     */
    public int getIsUnstall() {
        return isUnstall;
    }

    /**
     * @see #isUnstall
     * @param isUnstall
     *            the isUnstall to set
     */
    public void setIsUnstall(int isUnstall) {
        this.isUnstall = isUnstall;
    }

    /**
     * @see #appType
     * @return the appType
     */
    public int getAppType() {
        return appType;
    }

    /**
     * @see #appType
     * @param appType
     *            the appType to set
     */
    public void setAppType(int appType) {
        this.appType = appType;
    }

    /**
     * @see #updateType
     * @return the updateType
     */
    public int getUpdateType() {
        return updateType;
    }

    /**
     * @see #updateType
     * @param updateType
     *            the updateType to set
     */
    public void setUpdateType(int updateType) {
        this.updateType = updateType;
    }

    /**
     * @see #isLocalApp
     * @return the isLocalApp
     */
    public boolean isLocalApp() {
        return isLocalApp;
    }

    /**
     * @see #isLocalApp
     * @param isLocalApp
     *            the isLocalApp to set
     */
    public void setLocalApp(boolean isLocalApp) {
        this.isLocalApp = isLocalApp;
    }

    /**
     * @see #iconBitmap
     * @return the iconBitmap
     */
    public Bitmap getIconBitmap() {
        return iconBitmap;
    }

    /**
     * @see #iconBitmap
     * @param iconBitmap
     *            the iconBitmap to set
     */
    public void setIconBitmap(Bitmap iconBitmap) {
        this.iconBitmap = iconBitmap;
    }

    /**
     * @see #installState
     * @return the installState
     */
    public int getInstallState() {
        return installState;
    }

    /**
     * @see #installState
     * @param installState
     *            the installState to set
     */
    public void setInstallState(int installState) {
        this.installState = installState;
    }

    private void readFromParcel(Parcel in) {
        appid = in.readString();
        appname = in.readString();
        apkname = in.readString();
        path = in.readString();
        productId = in.readString();
        remark = in.readString();
        img1 = in.readString();
        img2 = in.readString();
        ver = in.readString();
        isUnstall = in.readInt();
        appType = in.readInt();
        updateType = in.readInt();
        isLocalApp = in.readInt() == 1 ? true : false;
        iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
        installState = in.readInt();

    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(appid);
        out.writeString(appname);
        out.writeString(apkname);
        out.writeString(path);
        out.writeString(productId);
        out.writeString(remark);
        out.writeString(img1);
        out.writeString(img2);
        out.writeString(ver);
        out.writeInt(isUnstall);
        out.writeInt(appType);
        out.writeInt(updateType);
        out.writeInt(isLocalApp ? 1 : 0);
        out.writeParcelable(iconBitmap, flags);
        out.writeInt(installState);
    }

    public static final Parcelable.Creator<AppInfoEntity> CREATOR = new Creator<AppInfoEntity>() {

        @Override
        public AppInfoEntity[] newArray(int size) {
            return new AppInfoEntity[size];
        }

        @Override
        public AppInfoEntity createFromParcel(Parcel source) {
            AppInfoEntity rslt = new AppInfoEntity(source);
            return rslt;
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

}
